package sbcc.edu.blackjack;

import sbcc.edu.blackjack.command.Command;
import sbcc.edu.blackjack.command.CommandQueue;
import sbcc.edu.blackjack.command.client.ClientCommand;
import sbcc.edu.blackjack.command.server.ServerCommand;
import sbcc.edu.blackjack.command.table.TableCommand;

public class Player {
	private CommandQueue queue;
	private Hand hand;
	private int bet; //holds the players bet 
	private GameState state;
	private int tableNumber;
    private int id;
    private static int nextId = 1;

	
	public Player(CommandQueue cq){
		id = nextId++;
		bet = 0;
		queue = cq;
		state = GameState.STOPPED;
		hand = new Hand();
	}

	public void addCard(Card drawCard) {
		hand.addCard(drawCard);
	}


	public int numCards() {
		// count how many cards in players hand
		return hand.getCardCount();
	}

	public int handTotal() {
		// return the total of the cards in the players hand
		return hand.getTotal();
	}
	 
	public Hand getHand() {
		return hand;
		
	}
	public void setState(GameState s) {
		state = s;
		
	}

	public GameState getState() {
		return state;
	}

	public void setBet(int amount) {
		bet = amount;
	}

	public void setTableId(int id) {
		tableNumber = id;
	}

	public int getTableId() {
		return tableNumber;
	}

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

	public void sendCommand(Command c){
		queue.sendCommand(c);
	}
	
	public TableCommand getTableCommand() {
		//get a table command from the command queue, return null if none available
		return queue.getTableCommand();
	}
	
	public ClientCommand getClientCommand() {
		return queue.getClientCommand();
	}
	
	public ServerCommand getServerCommand() {
		//same as getMove, but for server commands
		return queue.getServerCommand();
	}

	public int getBet() {
		return bet;
	}
}